package pens.penObjects
{
	import flash.display.Sprite;
	
	import pens.interfaces.IPenPlayer;
	/**
	 * 笔基类 
	 * @author Administrator
	 * 
	 */	
	internal class ActionPenSprite extends Sprite implements IPenPlayer
	{
		protected var _width:Number=500;
		protected var _height:Number=400;
	
		
		protected var _penName:String
		public function get penName():String{return _penName}
		public function draw(w:Number,h:Number):void{
			
		}
		
		
		protected var _canDrow:Boolean=false;
		
		
		
		protected var _penDates:Vector.<PenDate>=new Vector.<PenDate>()
		public function get penDates():Vector.<PenDate>{return _penDates}
		
		
		public function ActionPenSprite()
		{
			super();
			_penName="基类"
		}
		/**
		 * 重签 
		 * 
		 */		
		public function resign():void
		{
		    _penDates.length=0;
			drawFloor()
		}
	
		public function moveTo(x:Number, y:Number, size:Number=10, color:uint=0):void{
			_canDrow=true
			_penDates.push(new PenDate(_penName,size,color,x,y,PenDate.MOVE_TO))
			_moveTo(x,y,size,color)
		}
		
		protected function _moveTo(x:Number, y:Number, size:Number=10, color:uint=0):void{ 
			
		}
		/**
		 * 画向 
		 * @param x
		 * @param y
		 * @param size
		 * @param color
		 * 
		 */		
		public function lineTo(x:Number, y:Number, size:Number=10, color:uint=0):void{
			if(!_canDrow)return
			_penDates.push(new PenDate(_penName,size,color,x,y,PenDate.LINE_TO))
			_lineTo(x,y,size,color)
			
		}
		protected function _lineTo(x:Number, y:Number, size:Number=10, color:uint=0):void{
			
		}
		
		public function end():void{ 
			_canDrow=false
			_penDates.push(new PenDate(_penName,0,0,0,0,PenDate.END))
			_end()
		}
		protected function _end():void{
			
		}
		/**
		 * 清除内存 
		 * 
		 */		
		public function dispose():void{}
		
		
		/**
		 * 
		 * @param value
		 * 
		 */
		override public function set width(value:Number):void{
			if(_width==value) return
			_width=value
			drawFloor()
		}
		override public function get width():Number{return _width}
		/**
		 * 
		 * @param value
		 * 
		 */		
		override public function set height(value:Number):void{
			if(_height==value) return
			_height=value
			drawFloor()
		}
		override public function get height():Number{return _height}
		
		
		//////////////////////////
		protected function drawFloor():void{
			graphics.clear()
			graphics.beginFill(0xffffff,0)
			graphics.drawRect(0,0,_width,_height)
			graphics.endFill()
		}
	}
}